package rad.framework.mda.generator.template.test.java.seam;

import java.util.*;
import rad.framework.mda.generator.util.*;
import org.eclipse.emf.codegen.util.*;
import org.eclipse.uml2.uml.*;

public class PageflowJUnit
{
  protected static String nl;
  public static synchronized PageflowJUnit create(String lineSeparator)
  {
    nl = lineSeparator;
    PageflowJUnit result = new PageflowJUnit();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "package ";
  protected final String TEXT_2 = ";" + NL;
  protected final String TEXT_3 = NL + NL + "public class ";
  protected final String TEXT_4 = "Test extends PageflowTest {" + NL + "" + NL + "\t/** @generated */" + NL + "\tpublic static Test suite() {" + NL + "\t\tTestSuite suite = new TestSuite();" + NL + "\t\tsuite.addTest(new ";
  protected final String TEXT_5 = "Test(\"testPageflow\"));" + NL + "\t\treturn new Bootstrap(suite);" + NL + "\t}" + NL + "" + NL + "\t/** @generated */" + NL + "\tpublic ";
  protected final String TEXT_6 = "Test(String name) {" + NL + "\t\tsuper(name);" + NL + "\t}" + NL + "" + NL + "\t/** @generated */" + NL + "\tprotected void setUp() throws Exception {" + NL + "\t\tsuper.setUp();" + NL + "\t\tPage page; // use to setup form value metadata - addValue(expression, value)";
  protected final String TEXT_7 = NL + "\t\tpage = addPage(\"";
  protected final String TEXT_8 = "Page\", " + NL + "\t\t\tPREFIX + \"";
  protected final String TEXT_9 = "/Pageflow\" + EXTENSION," + NL + "\t\t\t";
  protected final String TEXT_10 = ");";
  protected final String TEXT_11 = NL + "\t}" + NL + "}";
  protected final String TEXT_12 = NL;

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    

    Region region = (Region) argument;
    stringBuffer.append(TEXT_1);
    stringBuffer.append(NameHelper.getQualifiedName(region.getStateMachine()));
    stringBuffer.append(TEXT_2);
    ImportManager importManager = ImportHelper.makeImportManager("");
    ImportHelper.addImport(region);
    importManager.addImport("junit.framework.Test");
    importManager.addImport("junit.framework.TestSuite");
    importManager.addImport("rad.framework.embedded.Bootstrap");
    importManager.addImport("rad.framework.testing.PageflowTest");
    stringBuffer.append(TEXT_3);
    stringBuffer.append(NameHelper.getCapName(region));
    stringBuffer.append(TEXT_4);
    stringBuffer.append(NameHelper.getCapName(region));
    stringBuffer.append(TEXT_5);
    stringBuffer.append(NameHelper.getCapName(region));
    stringBuffer.append(TEXT_6);
    for (Iterator<State> j=JsfHelper.getPages(region); j.hasNext();) { State state = (State)j.next();
    stringBuffer.append(TEXT_7);
    stringBuffer.append(NameHelper.getCapName(region));
    stringBuffer.append(NameHelper.getCapName(state));
    stringBuffer.append(TEXT_8);
    stringBuffer.append(NameHelper.getCapName(region));
    stringBuffer.append(TEXT_9);
    stringBuffer.append(JsfHelper.getPageActions(state));
    stringBuffer.append(TEXT_10);
    }
    stringBuffer.append(TEXT_11);
    stringBuffer.append(TEXT_12);
    return stringBuffer.toString();
  }
}
